package schemax

import (
	"gitee.com/zhongguo168a/gocodes/datax/schemax/basickind"
)

type IType interface {
	String() string
}

type MapType struct {
	Key   IType
	Value IType
}

func (typ *MapType) RefType() string {
	return "map"
}
func (typ *MapType) String() string {
	return "map[" + typ.Key.String() + "]" + typ.Value.String()
}

type FuncType struct {
	Args    []*Field
	Results []*Field
}

func (typ *FuncType) RefType() string {
	return "func"
}
func (typ *FuncType) String() string {
	return "func"
	//return "func(" + func() (x string) {
	//	var a []string
	//	for _, val := range typ.Args {
	//		a = append(a, val.String())
	//	}
	//	return strings.Join(a, ",")
	//}() + ")" + func() (x string) {
	//	if len(typ.Results) == 0 {
	//		return
	//	}
	//	var a []string
	//	for _, val := range typ.Results {
	//		a = append(a, val.String())
	//	}
	//	return "(" + strings.Join(a, ",") + ")"
	//}()
}

type ClassType struct {
	Decl string
}

func (typ *ClassType) RefType() string {
	return "class"
}

func (typ *ClassType) String() string {
	return typ.Decl
}

type EnumType struct {
	Decl string
}

func (typ *EnumType) RefType() string {
	return "enum"
}
func (typ *EnumType) String() string {
	return typ.Decl
}

type ArrayType struct {
	Elem IType
}

func (typ *ArrayType) RefType() string {
	return "array"
}
func (typ *ArrayType) String() string {
	return typ.Elem.String()
}

type BasicType struct {
	Kind basickind.Kind
}

func (typ *BasicType) RefType() string {
	return "basic"
}
func (typ *BasicType) String() string {
	return typ.Kind.String()
}

type AnyType struct {
}

func (typ *AnyType) RefType() string {
	return "any"
}
func (typ *AnyType) String() string {
	return "any"
}
